package org.yunai.swjg.server.module.inventory.container;

import org.yunai.swjg.server.module.inventory.item.Item;
import org.yunai.swjg.server.module.inventory.item.ItemDef;
import org.yunai.swjg.server.module.player.vo.Player;

import java.util.HashMap;
import java.util.Map;

/**
 * 玩家装备包
 * User: yunai
 * Date: 13-4-6
 * Time: 下午4:46
 */
public class PlayerEquipBag extends CommonBag {

//    private final EnumMap<ItemDef.EquipPosition, Item> equipMap =
//            new EnumMap<>(ItemDef.EquipPosition.class);
    /**
     * 装备背包规定大小为6
     */
    private static final int SIZE = 6;
    /**
     * 装备类型与背包位置规定MAP
     */
    private static final Map<ItemDef.Type, Integer> typePositionMap = new HashMap<>(SIZE);
    static {
        int position = 0;
        typePositionMap.put(ItemDef.Type.MAIN_HAND, ++position);
        typePositionMap.put(ItemDef.Type.OFF_HAND, ++position);
        typePositionMap.put(ItemDef.Type.CLOTHES, ++position);
        typePositionMap.put(ItemDef.Type.CAP, ++position);
        typePositionMap.put(ItemDef.Type.MOUNT, ++position);
        typePositionMap.put(ItemDef.Type.WAISTBAND, ++position);
    }

    public PlayerEquipBag(Player owner, BagType bagType) {
        super(owner, bagType, SIZE);
    }

    @Override
    public void putItem(Item item) {
        super.putItem(item);

        // TODO 将装备放到equipMap，
        // TODO 等Template想好之后，在弄这里,因为Position靠Template来确定
    }

    /**
     * @param type 装备类型
     * @return 获得该装备类型的装备
     */
    public Item getEquipment(ItemDef.Type type) {
        return super.getByIndex(this.getPosition(type));
    }

    /**
     * @param type 装备类型
     * @return 获得装备类型的背包位置
     */
    public int getPosition(ItemDef.Type type) {
        return typePositionMap.get(type);
    }

    @Override
    public void onLoad() {
        // TODO 未实现
    }

    @Override
    public void onChanged() {
        // TODO 未实现
    }
}
